/*
 * Copyright 2009 Eat Local Food, LLC
 * Copyright (c) 2007 osCommerce (this file was written after
 * code review of osCommerce).
 *
 * This file is part of gwtCommerce.
 *
 * gwtCommerce is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * gwtCommerce is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with gwtCommerce.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.elf.gwt.common.client.model;

import com.google.gwt.json.client.JSONObject;

public class ProductMetaModel extends AbstractModel
{	
	protected int cartQuantityMax;
	protected boolean displayCart;
	protected double imageHeightMax;
	protected double imageWidthMax;
	protected int maxRows;
	protected int offset;
	protected int pageLinksMax;
	protected int prevNextBarLocation;
	protected boolean returnDetails;
	protected boolean returnPageInfo;
	protected int rows;
	protected int totalRows;

	public ProductMetaModel()
	{
		displayCart = false;
		imageWidthMax = 1;
		imageHeightMax = 1;
		cartQuantityMax = 1;
		returnDetails = false;
		returnPageInfo = false;

		maxRows = 0;
		pageLinksMax = 0;
		prevNextBarLocation = 0;
		offset = 0;
		rows = 0;
		totalRows = 0;
	}

	public ProductMetaModel(JSONObject jsonObject)
	{
		this();
		displayCart = convertToBoolean(jsonObject,"display_cart");
		imageWidthMax = convertToDouble(jsonObject,"image_width_max");
		imageHeightMax = convertToDouble(jsonObject,"image_height_max");
		cartQuantityMax = convertToInteger(jsonObject,"qty_in_cart_max");
		returnDetails = convertToBoolean(jsonObject,"return_details");
		returnPageInfo = convertToBoolean(jsonObject,"return_page_info");
		prevNextBarLocation = convertToInteger(jsonObject, "prev_next_bar_location");
		
		if (returnPageInfo)
		{
			maxRows = convertToInteger(jsonObject, "max_rows");
			pageLinksMax = convertToInteger(jsonObject, "page_links_max");
			offset = convertToInteger(jsonObject, "offset");
			rows = convertToInteger(jsonObject, "rows");
			totalRows = convertToInteger(jsonObject, "total_rows");
		}
	}

	public int getCartQuantityMax() {
		return cartQuantityMax;
	}
	public double getImageHeightMax() {
		return imageHeightMax;
	}
	public double getImageWidthMax() {
		return imageWidthMax;
	}
	public int getMaxRows() {
		return maxRows;
	}
	public int getOffset() {
		return offset;
	}
	public int getPageLinksMax() {
		return pageLinksMax;
	}
	public int getPrevNextBarLocation() {
		return prevNextBarLocation;
	}
	public int getRows() {
		return rows;
	}
	public int getTotalRows() {
		return totalRows;
	}
	public boolean isDisplayCart() {
		return displayCart;
	}
	public boolean isReturnDetails() {
		return returnDetails;
	}
	public boolean isReturnPageInfo() {
		return returnPageInfo;
	}
}
